<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<!-- import common templates -->
<xsl:import href="../xml/templates/common.xsl"/>
<!-- import main_app templates -->
<xsl:import href="../xml/templates/nav_app.xsl"/>
<!-- xsl output -->
<xsl:output method='html' encoding='UTF-8' doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" indent='yes'/>
	
	<!-- template to generate main content -->
	<xsl:template name="ManageContent">
		<!-- load extra tabindex params 
		<xsl:call-template name="ExtraDataLoader">
			<xsl:with-param name="src" select="extradata/tabindex"/>
		</xsl:call-template> -->
		<!-- main tab page -->
		<div id="tab_wrapper">
			<h1>Manage Feeds Subscriptions</h1>
			<!-- create Group -->
		    <form  method="post" id="createg_form" action="../cgi-bin/managemovecreate.pl">
				<fieldset><legend>Create a Group</legend>
					<a href="../help/walkthrough.html#create" onclick="return false;" rel="A group is a way to organize your feeds. Grouping feeds by topic, interest or whatever you want makes easier to find what you need when you're browsing your news."><img class="help_ico" id="cgroup_help" src="../images/icons/help.png" alt="help"  /></a>
					<label for="cgroup">Insert a name for the group you want to create </label> <input type="text" id="cgroup" name="cgroup" maxlength="18"/>
					<!-- error -->
					<xsl:if test="input/err_type and input/create">
						<span class="error_box" id="last_name_err"><xsl:value-of select="input/err_type"/></span>
					</xsl:if>
					
					<input type="submit" id="cgroup_button" value="Create Group"/>					
					<!-- id value -->
					<input type="hidden" name="id">
						<xsl:attribute name="value"><xsl:value-of select="input/id"/></xsl:attribute>
					</input>
					<!-- create notify -->
					<input type="hidden" name="create" value="true"/>
				</fieldset>
			</form>
			<!-- change name Group -->
			<form  method="post" id="changeg_form">
				<fieldset><legend>Change Group Name</legend>
				<a href="../help/walkthrough.html#change" onclick="return false;" rel="This form helps you to change the name of a group. Select a group between yours and insert a new name for that group. When you push the button below, the name of the group will be changed."><img class="help_ico" id="cngroup_help" src="../images/icons/help.png" alt="help"  /></a>
				<label for="dgroup">Select a group to change its name</label> 
					<select id="sel_changeg" name="sel_changeg" >
						<xsl:for-each select="$src_data/userfeed/group">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="@groupname"/></xsl:attribute>
								<xsl:value-of select="@groupname"/>
							</option>
						</xsl:for-each>
					</select>
					<label for="changeg">Insert a new name for the group above</label> <input type="text" id="changeg" name="ngroup" maxlength="18"/>
					<!-- error -->
					<xsl:if test="input/err_type and input/sel_changeg">
						<span class="error_box" id="last_name_err"><xsl:value-of select="input/err_type"/></span>
					</xsl:if>					
					<input type="submit" id="changeg_button" value="Change Group Name"/>
					<!-- id value -->
					<input type="hidden" name="id">
						<xsl:attribute name="value"><xsl:value-of select="input/id"/></xsl:attribute>
					</input>
				</fieldset>
			</form>
			<!-- delete Group -->
			<form  method="post" id="deleteg_form" action="../cgi-bin/managemovecreate.pl">
				<fieldset><legend>Delete a Group</legend>
					<a href="../help/walkthrough.html#delete" onclick="return false;" rel="Select a group you want to delete and press the button. The group will be permanently deleted only if it is empty, that is if there are no feeds in it. If there are feeds inside, you have to previously move them to another group using the 'Organize your feeds' form in this page."><img class="help_ico" id="dgroup_help" src="../images/icons/help.png" alt="help"  /></a>
					<label for="dgroup">Select the group you want to delete</label> 
					<select id="dgroup" name="dgroup">
						<xsl:for-each select="$src_data/userfeed/group">
							<option>
								<xsl:attribute name="value"><xsl:value-of select="@groupname"/></xsl:attribute>
								<xsl:value-of select="@groupname"/>
							</option>
						</xsl:for-each>
					</select>
					<!-- error -->
					<xsl:if test="input/err_type and input/dgroup">
						<span class="error_box" id="last_name_err"><xsl:value-of select="input/err_type"/></span>
					</xsl:if>					
					<input type="submit" id="dgroup_button" value="Delete Selected Group"/>
					<!-- id value -->
					<input type="hidden" name="id">
						<xsl:attribute name="value"><xsl:value-of select="input/id"/></xsl:attribute>
					</input>
				</fieldset>
			</form>
			<!-- move Feeds -->
			<form action="../cgi-bin/managemovecreate.pl" method="post" id="subs_form">
			<fieldset><legend>Organize your feeds</legend>
				<a href="../help/walkthrough.html#organize" onclick="return false;" rel="Here you can move your feeds between groups just by selecting the group you want to move the feed in next to its name."><img class="help_ico" id="cgroup_help" src="../images/icons/help.png" alt="help"  /></a>
				<table id="feed_table" summary="This is the list of your feeds, divided by groups. Each row contains the name of the feed and a selection of groups where you can move that feed (obviously without the group which it already belongs to). To apply your movements, click on the button 'Move Selected' below the table or reset your moves with the 'Reset' button" cellspacing="0">   
					<colgroup>
						<col class="tb_name" />
						<col class="tb_group" />
					</colgroup>      
					<thead>
						<tr>
							<th axis="Feed name" scope="col">Feed Name</th>
							<th axis="Possible groups" scope="col" >Move to</th>
						</tr>
					</thead>
					<tbody>
						<xsl:for-each select="$src_data/userfeed/group">
							<tr class="group_title">
								<td colspan="3"><xsl:value-of select="concat(@groupname,' Group')"/></td>
							</tr>
							<!-- if got child -->
							<xsl:if test="feed">
								<xsl:variable name="groupname" select="@groupname"/>
								<xsl:for-each select="feed">
									<tr class="odd">
										<td><xsl:value-of select="name"/></td>
										<td><select>
											<xsl:attribute name="name"><xsl:value-of select="name"/></xsl:attribute>
											<option selected="selected"/>
											<!-- other groups -->
											<xsl:call-template name="GroupsLoader">
												<xsl:with-param name="src" select="$src_data"/>
												<xsl:with-param name="groupname" select="$groupname"/>
											</xsl:call-template>
										</select></td>
									</tr>
								</xsl:for-each>
							</xsl:if>
							<!-- empty -->
							<xsl:if test="not(feed)">
								<tr class="empty_group"><td>&lt;empty></td></tr>
							</xsl:if>
						</xsl:for-each>
					</tbody>
				</table>
				<ul id="remove_tools">
					<li><input type="submit" value="Move Selected" /></li>
					<li><input type="reset" value="Reset" /></li>
				</ul>
				<!-- id value -->
				<input type="hidden" name="id">
					<xsl:attribute name="value"><xsl:value-of select="input/id"/></xsl:attribute>
				</input>
			</fieldset>
			</form>
		</div>
		<div id="msgCont">
		</div>
	</xsl:template>
	
	<!-- CREATE PAGE -->
	
	<!-- create page structure -->
	<xsl:template match="root">
		<html>
			<!-- head -->
			<head>
				<!-- load common code -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_head"/>
				</xsl:call-template>
				<!-- load extra head params -->
				<xsl:call-template name="ExtraDataLoader">
					<xsl:with-param name="src" select="extradata/head"/>
				</xsl:call-template>
				<!-- load ie fix -->
				<xsl:call-template name="IELoader">
					<xsl:with-param name="src" select="$src_head_ie/root/common"/>
				</xsl:call-template>
				<xsl:call-template name="IELoader">
					<xsl:with-param name="src" select="extradata/IEFix"/>
				</xsl:call-template>
				<!-- pagetitle -->
				<title><xsl:value-of select="pagetitle"/></title>
			</head>
			<body>
				<!-- body onload attribute -->
				<xsl:if test="extradata/body/onload/text() != ''">
					<xsl:attribute name="onLoad"><xsl:value-of select="extradata/body/onload"/></xsl:attribute>
				</xsl:if>
				<!-- header -->			
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_header"/>
				</xsl:call-template>
				<!-- profile -->
				<xsl:call-template name="ProfileLoader">
					<xsl:with-param name="sid" select="input/id"/>
					<xsl:with-param name="page" select="page"/>
				</xsl:call-template>
				<!-- navbar -->
				<div id="main_app_navigation">
					<xsl:call-template name="NavAppLoader">
						<xsl:with-param name="src" select="$src_navbar"/>
					</xsl:call-template>
				</div>
				<!-- content -->
				<xsl:call-template name="ManageContent">
					<!--<xsl:with-param name="src" select="$src_footer"/>-->
				</xsl:call-template>				
				<!-- footer -->
				<xsl:call-template name="Loader">
					<xsl:with-param name="src" select="$src_footer"/>
				</xsl:call-template>				
			</body>
		</html>
	</xsl:template>
	
</xsl:stylesheet>	
